package com.yunchuang.service;

import com.yunchuang.constants.FileStatusConstants;
import com.yunchuang.common.FileListener;

import java.io.File;

/**
 * 文件监听
 *
 * @author ItJiange
 * @date 2023/10/20
 */
public class FileListenerService extends FileListener {
    private static final FileUploadService fileUploadService = new FileUploadService();
    @Override
    public void onFileCreate(File file) {
        fileUploadService.sendFileMessage(file, FileStatusConstants.FILE_CREATE);
        System.out.println("创建文件 : " + file.getAbsolutePath());
    }

    @Override
    public void onFileChange(File file) {
        fileUploadService.sendFileMessage(file, FileStatusConstants.FILE_CHANGE);
        System.out.println("修改文件 : " + file.getAbsolutePath());
    }

    @Override
    public void onFileDelete(File file) {
        fileUploadService.sendFileMessage(file, FileStatusConstants.FILE_DELETE);
        System.out.println("删除文件 : " + file.getAbsolutePath());
    }
}
